home *** CD-ROM | disk | FTP | other *** search
/ Software Vault: The Gold Collection / Software Vault - The Gold Collection (American Databankers) (1993).ISO / cdr12 / pplasc.zip / PPL1.ASC next >
Text File  |  1993-06-04  |  31KB  |  715 lines

  1.  
  2.  
  3.  
  4.  
  5.  
  6.  
  7.  
  8.  
  9.                       
  10.  
  11.  
  12.  
  13.           PPL Structure
  14.  
  15.                Basics
  16.  
  17.                       A PPL  program is created by  a programmer with a  standard text
  18.                           editor.  Each  line consists of standard ASCII text  (up to 2048
  19.                           characters long)  terminated with  a carriage  return/line  feed
  20.                           pair.   Character case is not significant except in literal text
  21.                           strings.  Three  types of lines are recognized by  the compiler:
  22.                           comment   lines,  variable   declaration  statements   and  code
  23.                           statements.
  24.  
  25.                        Comments
  26.                       Comments  are used by  the PPL  programmer to make  notes in the
  27.                           source code about what the code is supposed to  do and generally
  28.                           clarify things  so that code  maintenance is easier.   They  are
  29.                           completely ignored by  the PPL compiler so they may  contain any
  30.                           text  desired.  A comment may be  on a line all  by itself or at
  31.                           the end of  a line after  a valid  statement.  A  blank line  is
  32.                           considered  a comment.  Any text following a quote character (')
  33.                           or semi-colon  (;) is  also a comment.   The  following are  all
  34.                           valid comments:
  35.                              ; This is a comment line
  36.                         STRING buf, str, ssNum ' This is a comment too
  37.  
  38.                         ' The blank line above this (as well as these
  39.                         ' lines) are all comments
  40.                         CLS                    ; Yet *ANOTHER* comment!
  41.  
  42.                    Variable Declaration Statements
  43.  
  44.                       Variable  declaration  statements  must  start  with  a  keyword
  45.                           denoting the  variable type.   Valid type keywords  are BOOLEAN,
  46.                           DATE,  INTEGER, MONEY,  STRING and  TIME.   The keyword  must be
  47.                           followed  by  one  or  more  valid  variable   names  (or  array
  48.                           declarations) which should be separated by commas  (,).  A valid
  49.                           variable  name must start  with a  letter (A-Z)  and may contain
  50.                           letters, numbers  (0-9) and the  underscore character (_).   Any
  51.                           number of characters may be  used but only the first 32  will be
  52.                           recognized by PPL.   If the variable is  an array then the  name
  53.                           should be followed by an open parenthesis [(], one, two or three
  54.                           constant  subscript  expressions  (separated  by   commas),  and
  55.                           finally a closing parenthesis [)].  Here are some examples:
  56.  
  57.                         BOOLEAN adultFlag
  58.                         DATE    this_IS_a_VARIABLE_to_HOLD_todays_DATE
  59.                         ; Only this_IS_a_VARIALBE_to_HOLD_today is
  60.                         significant
  61.                         INTEGER age
  62.  
  63.  
  64.  
  65.  
  66.  
  67.  
  68.  
  69.                       
  70.  
  71.                         MONEY   prices(2,5)
  72.                         STRING  buf, labels(10), ssNum
  73.                         TIME    start, stop
  74.  
  75.                    Code Statements
  76.                       Code declaration statements must start with a keyword indicating
  77.                           the  operation  or  process  to  be  performed.   There  is  one
  78.                           exception to this rule, however,  and that is the LET statement.
  79.                           If  no  keyword is  found at  the  beginning of  a  line, a  LET
  80.                           statement is implied and the rest of  the line should follow the
  81.                           format:
  82.                              VAR = EXPRESSION
  83.  
  84.                       There are many statements  defined in PPL  and it is beyond  the
  85.                           scope of this part of the manual to cover the precise syntax for
  86.                           each and every one of them.  Simply put, a statement takes zero,
  87.                           one  or more expressions (see Expressions later in this section)
  88.                           and/or variable  names (see Variable  Declaration Statements) as
  89.                           arguments (separated  by  commas),  does  something,  using  any
  90.                           passed expressions  and/or variables, and  assigning new values,
  91.                           as  needed,  to  passed  variables.    Here  are  a  few  sample
  92.                           statements:
  93.                              ' This statement clears the screen and takes no
  94.                         arguments
  95.                         CLS
  96.  
  97.                         ' Evaluates the single expression and assigns the
  98.                         result to ans
  99.                         LET ans = 5+4*3/2-1
  100.  
  101.                         ; Evaluates all three (could be more, could be
  102.                         less) expressions (two of
  103.                         ; which have only one term) and prints them in
  104.                         order, following them
  105.                         ; with a carriage return
  106.                         PRINTLN "The answer "+"is ",STRING(ans),"."
  107.  
  108.                         ; Evaluate the expression on the left, display it,
  109.                         then get a string
  110.                         ; from the user and assign it to the variable name
  111.                         on the left
  112.                         INPUT "What is "+"your age",current_Age
  113.  
  114.                       Here are the valid statements accepted in PPL source code:
  115.                                                ADJTIME
  116.                                        ANSIPOS
  117.                                         BACKUP
  118.                                          BLT
  119.                                       BROADCAST
  120.                                          BYE
  121.                                          CALL
  122.                                        CDCHKOFF
  123.  
  124.  
  125.  
  126.  
  127.  
  128.  
  129.  
  130.                           
  131.  
  132.                                                CDCHKON
  133.                                          CHAT
  134.                                        CLOSECAP
  135.                                         CLREOL
  136.                                          CLS
  137.                                         COLOR
  138.                                        CONFFLAG
  139.                                       CONFUNFLAG
  140.                                        DBGLEVEL
  141.                                          DEC
  142.                                        DEFCOLOR
  143.                                         DELAY
  144.                                         DELETE
  145.                                        DELUSER
  146.                                          DIR
  147.                                        DISPFILE
  148.                                        DISPSTR
  149.                                        DISPTEXT
  150.                                         DOINTR
  151.                                         DTROFF
  152.                                         DTRON
  153.                                          ELSE
  154.                                         ELSEIF
  155.                                          END
  156.                                         ENDIF
  157.                                        ENDWHILE
  158.                                        FAPPEND
  159.                                         FCLOSE
  160.                                        FCREATE
  161.                                          FGET
  162.                                         FOPEN
  163.                                          FOR
  164.                                        FORWARD
  165.                                          FPUT
  166.                                         FPUTLN
  167.                                        FPUTPAD
  168.                                       FRESHLINE
  169.                                        FREWIND
  170.                                        GETTOKEN
  171.                                        GETUSER
  172.                                        GOODBYE
  173.                                         GOSUB
  174.                                          GOTO
  175.                                         HANGUP
  176.                                           IF
  177.                                          INC
  178.                                         INPUT
  179.                                        INPUTCC
  180.                                       INPUTDATE
  181.                                        INPUTINT
  182.                                       INPUTMONEY
  183.                                        INPUTSTR
  184.  
  185.  
  186.  
  187.  
  188.  
  189.  
  190.  
  191.                           
  192.  
  193.                                               INPUTTEXT
  194.                                       INPUTTIME
  195.                                        INPUTYN
  196.                                          JOIN
  197.                                       KBDCHKOFF
  198.                                        KBDCHKON
  199.                                        KBDFILE
  200.                                        KBDSTUFF
  201.                                          LET
  202.                                          LOG
  203.                                        MESSAGE
  204.                                          MORE
  205.                                         MPRINT
  206.                                        MPRINTLN
  207.                                        NEWLINE
  208.                                        NEWLINES
  209.                                         NEWPWD
  210.                                          NEXT
  211.                                        OPENCAP
  212.                                         OPTEXT
  213.                                        PAGEOFF
  214.                                         PAGEON
  215.                                         POKEB
  216.                                         POKEDW
  217.                                         POKEW
  218.                                          POP
  219.                                         PRINT
  220.                                        PRINTLN
  221.                                       PROMPTSTR
  222.                                          PUSH
  223.                                        PUTUSER
  224.                                         QUEST
  225.                                         RDUNET
  226.                                         RDUSYS
  227.                                         RENAME
  228.                                       RESETDISP
  229.                                        RESTSCRN
  230.                                         RETURN
  231.                                        SAVESCRN
  232.                                       SENDMODEM
  233.                                         SHELL
  234.                                        SHOWOFF
  235.                                         SHOWON
  236.                                         SOUND
  237.                                         SPRINT
  238.                                        SPRINTLN
  239.                                       STARTDISP
  240.                                          STOP
  241.                                        TOKENIZE
  242.                                        VARADDR
  243.                                         VAROFF
  244.                                         VARSEG
  245.  
  246.  
  247.  
  248.  
  249.  
  250.  
  251.  
  252.                           
  253.  
  254.                                                  WAIT
  255.                                        WAITFOR
  256.                                         WHILE
  257.                                         WRUNET
  258.                                         WRUSYS
  259.  
  260.  
  261.  
  262.  
  263.  
  264.  
  265.  
  266.                           
  267.  
  268.  
  269.  
  270.                   Expressions
  271.                       An  expression in PPL  can take just about  any form imaginable.
  272.                           It  consists of one  or more constants,  variables (see Variable
  273.                           Declaration Statements), functions (which take zero, one or more
  274.                           arguments), or  sub-expressions, all  of which are  separated by
  275.                           PPL  operators.  Although  most statements and  functions in PPL
  276.                           expect expressions of a specific type as arguments, you need not
  277.                           pass   it  an   expression  of   the  correct  type;   PPL  will
  278.                           automatically convert from one type to another when it needs to.
  279.                           Here are a few sample expressions:
  280.  
  281.                              ' Define a few variables to hold expression results
  282.                         INTEGER i, j, k
  283.                         STRING s, t, u
  284.  
  285.                         ' Single term expressions
  286.                         ' (All expressions here are to the right of the =)
  287.                         LET i = 2
  288.                         LET j = 3
  289.                         LET k = 4
  290.                         LET s = "STRING"
  291.  
  292.                         ' Complex expressions
  293.                         LET i = i*j*k+2*i+3*j+k/2-5
  294.                         LET j = i*j*(k+2)*(i+3)*(j+k)/(2-5)
  295.                         LET k = (RANDOM(5)+1)*5+ABS(j)
  296.                         LET t = CHR(i%256)
  297.                         LET u = s+" "+t
  298.  
  299.  
  300.                        Constants
  301.                       PPL  supports  both   user  defined  constants  and  pre-defined
  302.                           constants.  User defined constants may be any of the following:
  303.                                 $#.## A MONEY constant  (dollar sign followed  by optional
  304.                           dollars followed by decimal point followed by cents; # = 0-9)
  305.  
  306.                                 ##h   An  INTEGER hexadecimal  constant  (a  decimal digit
  307.                           followed by zero,  one or more hexadecimal digits followed by an
  308.                           H; # = 0-9 & A-F)
  309.                                 ##d   An  INTEGER decimal  constant (one  or more  decimal
  310.                           digits followed by a D; # = 0-9)
  311.                                 ##o   An INTEGER octal constant (one or  more octal digits
  312.                           f    o    l    l    o    w    e    d   b    y   a    n    O    ;
  313.  
  314.                           # = 0-7)
  315.  
  316.                                 ##b   An  INTEGER  binary  constant  (one or  more  binary
  317.                           d i g i t s        f o l l o w e d        b y        a       B ;
  318.  
  319.  
  320.  
  321.  
  322.  
  323.  
  324.  
  325.                           
  326.  
  327.                           # = 0-1)
  328.                                 +/-## An INTEGER constant (an  optional plus or minus sign
  329.                           followed by one or more decimal digits; # = 0-9)
  330.                                 "X"   A  STRING  constant  (a  double  quote  followed  by
  331.                           displayable text  followed  by  another double  quote; X  =  any
  332.                           displayable text)
  333.  
  334.                                 @X##  An  INTEGER  @X   constant  (a  commercial  at  sign
  335.                           followed by an X  followed by two hexadecimal digits; #  = 0-9 &
  336.                           A-F)
  337.                           The following  predefined  constant labels  are also  available.
  338.                           Their values and uses will be defined later.
  339.                                                  AUTO
  340.                                          BELL
  341.                                          DEFS
  342.                                        ECHODOTS
  343.                                       ERASELINE
  344.                                         FALSE
  345.                                          FCL
  346.                                        FIELDLEN
  347.                                          FNS
  348.                                         F_EXP
  349.                                          F_MW
  350.                                         F_REG
  351.                                         F_SEL
  352.                                         F_SYS
  353.                                         GRAPH
  354.                                         GUIDE
  355.                                       HIGHASCII
  356.                                          LANG
  357.                                        LFAFTER
  358.                                        LFBEFORE
  359.                                         LOGIT
  360.                                       LOGITLEFT
  361.                                           NC
  362.                                        NEWLINE
  363.                                        NOCLEAR
  364.                                          O_RD
  365.                                          O_RW
  366.                                          O_WR
  367.                                          SEC
  368.                                        STACKED
  369.                                          S_DB
  370.                                          S_DN
  371.                                          S_DR
  372.                                          S_DW
  373.                                          TRUE
  374.                                         UPCASE
  375.                                        WORDWRAP
  376.                                         YESNO
  377.  
  378.  
  379.  
  380.  
  381.  
  382.  
  383.  
  384.                       
  385.  
  386.                    Functions
  387.                       PPL  supports many functions which may be used by the programmer
  388.                           in expressions.  Here is a list of valid PPL functions.  As with
  389.                           the predefined constants, their return  values and uses will  be
  390.                           documented later.
  391.                                                 ABORT
  392.                                          ABS
  393.                                          AND
  394.                                         ANSION
  395.                                          ASC
  396.                                          B2W
  397.                                         CALLID
  398.                                        CALLNUM
  399.                                        CARRIER
  400.                                         CCTYPE
  401.                                          CDON
  402.                                          CHR
  403.                                        CURCOLOR
  404.                                        CURCONF
  405.                                         CURSEC
  406.                                          DATE
  407.                                          DAY
  408.                                        DBGLEVEL
  409.                                        DEFCOLOR
  410.                                          DOW
  411.                                         EXIST
  412.                                          FERR
  413.                                        FILEINF
  414.                                         FMTCC
  415.                                         GETENV
  416.                                        GETTOKEN
  417.                                          GETX
  418.                                          GETY
  419.                                        GRAFMODE
  420.                                        HELPPATH
  421.                                          HOUR
  422.                                          I2S
  423.                                         INKEY
  424.                                         INSTR
  425.                                         KINKEY
  426.                                        LANGEXT
  427.                                          LEFT
  428.                                          LEN
  429.                                        LOGGEDON
  430.                                         LOWER
  431.                                         LTRIM
  432.                                       MASK_ALNUM
  433.                                       MASK_ALPHA
  434.                                       MASK_ASCII
  435.                                       MASK_FILE
  436.                                        MASK_NUM
  437.  
  438.  
  439.  
  440.  
  441.  
  442.  
  443.  
  444.                           
  445.  
  446.                                               MASK_PATH
  447.                                        MASK_PWD
  448.                                        MAXNODE
  449.                                        MGETBYTE
  450.                                          MID
  451.                                          MIN
  452.                                         MINKEY
  453.                                        MINLEFT
  454.                                         MINON
  455.                                         MKADDR
  456.                                         MKDATE
  457.                                         MODEM
  458.                                         MONTH
  459.                                         NOCHAR
  460.                                          NOT
  461.                                        ONLOCAL
  462.                                           OR
  463.                                        PAGESTAT
  464.                                         PCBDAT
  465.                                        PCBNODE 
  466.                                         PEEKB
  467.                                         PEEKDW
  468.                                         PEEKW
  469.                                        PPENAME
  470.                                        PPEPATH
  471.                                          PSA
  472.                                         RANDOM
  473.                                        READLINE
  474.                                         REGAH
  475.                                         REGAL
  476.                                         REGAX
  477.                                         REGBH
  478.                                         REGBL
  479.                                         REGBX
  480.                                         REGCF
  481.                                         REGCH
  482.                                         REGCL
  483.                                         REGCX
  484.                                         REGDH
  485.                                         REGDI
  486.                                         REGDL
  487.                                         REGDS
  488.                                         REGDX
  489.                                         REGES
  490.                                          REGF
  491.                                         REGSI
  492.                                        REPLACE
  493.                                         RIGHT
  494.                                         RTRIM
  495.                                          S2I
  496.                                        SCRTEXT
  497.                                          SEC
  498.  
  499.  
  500.  
  501.  
  502.  
  503.  
  504.  
  505.                           
  506.  
  507.                                                SHOWSTAT
  508.                                         SLPATH
  509.                                         SPACE
  510.                                         STRING
  511.                                         STRIP
  512.                                        STRIPATX
  513.                                        SYSOPSEC
  514.                                        TEMPPATH
  515.                                          TIME
  516.                                         TIMEAP
  517.                                        TOKCOUNT
  518.                                        TOKENSTR
  519.                                          TRIM
  520.                                         UPPER
  521.                                        UN_CITY
  522.                                        UN_NAME
  523.                                        UN_OPER
  524.                                        UN_STAT
  525.                                         U_BDL
  526.                                        U_BDLDAY
  527.                                         U_BUL
  528.                                         U_FDL
  529.                                         U_FUL
  530.                                        U_INCONF
  531.                                        U_LDATE
  532.                                         U_LDIR
  533.                                        U_LOGONS
  534.                                        U_LTIME
  535.                                        U_MSGRD
  536.                                        U_MSGWR
  537.                                         U_NAME
  538.                                       U_PWDHIST
  539.                                        U_PWDLC
  540.                                        U_PWDTC
  541.                                        U_RECNUM
  542.                                         U_STAT
  543.                                        U_TIMEON
  544.                                         VALCC
  545.                                        VALDATE
  546.                                        VALTIME
  547.                                          VER
  548.                                          XOR
  549.                                          YEAR
  550.                                        YESCHAR
  551.  
  552.  
  553.                        Sub-Expressions
  554.  
  555.                       A sub-expression  is simply any valid  PPL expression surrounded
  556.                           by parentheses.  For example, this is an expression:
  557.                              7+6-5*4/3%2
  558.  
  559.  
  560.  
  561.  
  562.  
  563.  
  564.  
  565.                           
  566.  
  567.                           To make it  into a sub-expression, surround  it with parentheses
  568.                           like this:
  569.                              (7+6-5*4/3%2)
  570.  
  571.                       This sub-expression could be used in yet another expression:
  572.                              PRINTLN 2*(7+6-5*4/3%2)*RANDOM(4)
  573.  
  574.                    Operators
  575.                       PPL  supports  a  full  set of  operators  in  addition  to  the
  576.                           functions listed previously.  They are:
  577.                                 Operator    Function
  578.  
  579.                                 (    Starts  a sub-expression; requires a  ) to terminate
  580.  
  581.                           Example:  3*(2+1)  (result is 9, not 7)
  582.                                 )    E n d s         a        s u b - e x p r e s s i o n
  583.  
  584.                           Example:  3*(2+1)  (result is 9, not 7)
  585.                                 ^    Returns  the  result  of   raising  a  number  to  a
  586.                           s    p    e    c    i    f    i    e    d  p    o    w    e    r
  587.  
  588.                           E x p e c t s   a n d    r e t u r n s   t y p e   I N T E G E R
  589.  
  590.                           Example:  3^2  (result is 9)
  591.  
  592.                                 *    Returns     the    product     of    two     numbers
  593.  
  594.                           E x p e c t s   a n d    r e t u r n s   t y p e   I N T E G E R
  595.  
  596.                           Example:  3*2  (result is 6)
  597.                                 /    Returns    the     quotient    of    two     numbers
  598.  
  599.                           E x p e c t s   a n d   r e t u r n s   t y p e    I N T E G E R
  600.  
  601.                           Example:  9/4  (result is 2)
  602.  
  603.                                 %    Returns    the    remainder     of    two    numbers
  604.  
  605.                           E x p e c t s   a n d   r e t u r n s    t y p e   I N T E G E R
  606.  
  607.                           Example:  9%4  (result is 1)
  608.                                 +    Returns  the   sum  of  two  numbers   or  a  string
  609.                           c o n c a t e n a t e d             t o            a n o t h e r
  610.  
  611.                           Expects     and    returns     type    INTEGER     or     STRING
  612.  
  613.                           E x a m p l e :        1 + 2        ( r e s u l t    i s    3 )
  614.  
  615.                           Example:  "String plus  "+"String"  (result  is "String plus
  616.                           String")
  617.                                 -    Returns   the   difference   between   two   numbers
  618.  
  619.  
  620.  
  621.  
  622.  
  623.  
  624.  
  625.                           
  626.  
  627.  
  628.                           E x p e c t s   a n d    r e t u r n s   t y p e   I N T E G E R
  629.  
  630.                           Example:  3-2  (result is 1)
  631.                                 =    Returns    TRUE    if   two    values   are    equal
  632.  
  633.                           Expects      any      type;      returns      type       BOOLEAN
  634.  
  635.                           Example:         3     =    3          (result    is     TRUE)
  636.  
  637.                           Example:  "String" = "STRING"  (result is FALSE)
  638.                                 <>   Returns   TRUE   if  two   values   are  not   equal
  639.  
  640.                           Expects       any      type;      returns      type      BOOLEAN
  641.  
  642.                           Example:        3     <>    3         (result    is     FALSE)
  643.  
  644.                           Example:  "String" <> "STRING"  (result is TRUE)
  645.  
  646.                                 <    Returns  TRUE  if  a  value  is  less  than  another
  647.  
  648.                           Expects      any      type;       returns      type      BOOLEAN
  649.  
  650.                           Example:         2     <    3          (result    is     TRUE)
  651.  
  652.                           Example:  "STRING" < "STRING"  (result is FALSE)
  653.                                 <=   Returns TRUE  if a  value is  less than or  equal to
  654.                           a         n         o         t         h         e         r
  655.  
  656.                           Expects      any      type;       returns      type      BOOLEAN
  657.  
  658.                           Example:         2    <=     3         (result    is     TRUE)
  659.  
  660.                           Example:  "STRING" <= "STRING"  (result is TRUE)
  661.                                 >    Returns  TRUE  if a  value is  greater  than another
  662.  
  663.                           Expects      any      type;      returns       type      BOOLEAN
  664.  
  665.                           Example:         2     >    3          (result    is    FALSE)
  666.  
  667.                           Example:  "STRING" > "STRING"  (result is FALSE)
  668.  
  669.                                 >=   Returns TRUE if a value is greater  than or equal to
  670.                           a         n         o         t         h         e         r
  671.  
  672.                           Expects      any      type;      returns      type       BOOLEAN
  673.  
  674.                           Example:         2    >=     3        (result     is    FALSE)
  675.  
  676.                           Example:  "STRING" >= "STRING"  (result is TRUE)
  677.                                 !    Returns  the   logical  not  of   a  BOOLEAN   value
  678.  
  679.  
  680.  
  681.  
  682.  
  683.  
  684.  
  685.                           
  686.  
  687.  
  688.                           E x p e c t s   a n d    r e t u r n s   t y p e   B O O L E A N
  689.  
  690.                           Example:  !TRUE  (result is FALSE)
  691.                                 &    Returns  the  logical  and  of  two  BOOLEAN  values
  692.  
  693.                           E x p e c t s   a n d    r e t u r n s   t y p e   B O O L E A N
  694.  
  695.                           Example:  TRUE & FALSE  (result is FALSE)
  696.                                 |    Returns the logical or of two BOOLEAN values
  697.                           Expects and returns type BOOLEAN
  698.                           Example:  TRUE | FALSE  (result is TRUE)
  699.  
  700.                           PPL  operators  have  a  precedence  between  one  and six  that
  701.                           determines which operators get processed first.  A precedence of
  702.                           one gets processed first, six gets processed last.
  703.                                 Precedence  Operators
  704.                                 1     ( )
  705.                                 2     ^
  706.  
  707.                                 3     * / %
  708.                                 4     + -
  709.  
  710.                                 5     = <> < <= > >=
  711.                                 6     ! & |
  712.                           Binary operators expect  both the left and  right operands to be
  713.                           of the  same  type.   If  they  are not  then  appropriate  type
  714.                           conversions will be performed automatically.
  715.